/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package shaman.storage;

import java.util.List;
import javax.swing.table.AbstractTableModel;
import shaman.storage.api.Storage;

/**
 *
 * @author Shaman
 */
public class TableModelStorages extends AbstractTableModel {

    List<Storage> storages = null;
    
    public TableModelStorages(BackupTask task)
    {
        storages = task.getStorages();
    }

    public int getRowCount() {
        return storages.size();
    }

    public int getColumnCount() {
        return 3;
    }

    @Override
    public String getColumnName(int columnIndex)
    {
        switch (columnIndex)
        {
            case 0: return "Тип хранилища";
            case 1: return "Адрес";
            case 2: return "Комментарий";
        }
        return "NODE";
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        Storage curStorage = storages.get(rowIndex);
        switch (columnIndex)
        {
            case 0: return curStorage.getTypeName();
            case 1: return curStorage.getLocation();
            case 2: return curStorage.getComment();
        }
        return "NONE";
    }

}
